<!--
 * @Descripttion: 
 * @version: 
 * @Author: Jun
 * @Date: 2021-05-26 10:36:14
 * @LastEditors: Jun
 * @LastEditTime: 2021-06-01 15:46:36
-->
<template>
  <el-radio-group
    v-model="radio"
    @change="handlerChange"
    :disabled="isDisabled"
  >
    <el-radio
      v-for="item of valueArray"
      :key="item.label"
      :label="item.label"
      >{{ item.content }}</el-radio
    >
  </el-radio-group>
</template>

<script>
export default {
  props: {
    valueArray: {
      //数据数组
      type: Array,
      required: true,
    },
    currentItem: {
      //当前选中
      required: true,
    },
    isDisabled: {
      type: Boolean,
      default: false,
    },
  },
  model: {
    prop: "currentItem",
    event: "change",
  },
  data() {
    return {
      radio: this.currentItem ? this.currentItem : this.valueArray[0].label, //默认选中数据数组的第一个选项
    };
  },
  methods: {
    handlerChange(val) {
      this.$emit("change", val);
    },
  },
  created(){
    this.$emit("change", this.radio);
  }
};
</script>

<style>
</style>